﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace OrderEntryProject
{
    /// <summary>
    /// Interaction logic for OrderWindow.xaml
    /// </summary>
    public partial class OrderWindow : Window
    {
        public String CustomerId { get; set; }

        public OrderWindow()
        {
            InitializeComponent();
        }

        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            var context = Application.Current.Properties["Context"] as NorthwindDataContext;
            var order = new Order()
                            {
                                CustomerID = CustomerId,
                                OrderDate = dtOrder.SelectedDate,
                                RequiredDate = dtRequired.SelectedDate
                            };
            context.Orders.InsertOnSubmit(order);
            Close();
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }
    }
}
